<lib:EditControl x:Class="MoPlus.SolutionBuilder.WpfClient.UserControls.Solutions.TagManagementControl"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:VM="clr-namespace:MoPlus.ViewModel;assembly=MoPlus.ViewModel"
                     xmlns:SolutionsVM="clr-namespace:MoPlus.ViewModel.Solutions;assembly=MoPlus.ViewModel"
                     xmlns:UI="clr-namespace:MoPlus.SolutionBuilder.WpfClient"
                     xmlns:lib="clr-namespace:MoPlus.SolutionBuilder.WpfClient.Library"
                     xmlns:Settings="clr-namespace:MoPlus.SolutionBuilder.WpfClient.Library;assembly=MoPlus.SolutionBuilder.WpfClient"
                     mc:Ignorable="d" 
                     d:DesignHeight="300" d:DesignWidth="300">
 	<lib:EditControl.CommandBindings>
	</lib:EditControl.CommandBindings>
	<lib:EditControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../../Resources/Theme.xaml" />
			</ResourceDictionary.MergedDictionaries>
			<Style x:Key="TagManagementInput" BasedOn="{StaticResource LabelInput}" TargetType="{x:Type Label}">
				<Setter Property="Foreground" Value="Black" />
			</Style>
			<Style x:Key="TagNameInput" BasedOn="{StaticResource LabelInput}" TargetType="{x:Type Label}">
				<Setter Property="Foreground" Value="Black" />
				<Style.Triggers>
					<DataTrigger Binding="{Binding TagNameValidationMessage, Converter={StaticResource IsNullOrEmptyConverter}, Mode=OneWay}" Value="False">
						<DataTrigger.Setters>
							<Setter Property="Foreground" Value="Red" />
						</DataTrigger.Setters>
					</DataTrigger>
				</Style.Triggers>
			</Style>
		</ResourceDictionary>
	</lib:EditControl.Resources>
	<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Background="{StaticResource ControlBackgroundBrush}">
		<Grid MinWidth="400" MinHeight="400" DataContextChanged="Grid_DataContextChanged"
			  MaxWidth="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType=ScrollViewer}}"
			  RenderTransformOrigin="0.5,0.5">
			<Grid.LayoutTransform>
				<TransformGroup>
					<ScaleTransform ScaleX="{Binding Source={x:Static Settings:UserSettingsHelper.Instance}, Path=ControlSize, Mode=TwoWay}"
					                ScaleY="{Binding Source={x:Static Settings:UserSettingsHelper.Instance}, Path=ControlSize, Mode=TwoWay}"/>
				</TransformGroup>
			</Grid.LayoutTransform>			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"></RowDefinition>
				<RowDefinition Height="Auto"></RowDefinition>
				<RowDefinition Height="Auto"></RowDefinition>
				<RowDefinition Height="Auto"></RowDefinition>
				<RowDefinition Height="*"></RowDefinition>
				<RowDefinition Height="Auto"></RowDefinition>
				<RowDefinition Height="Auto"></RowDefinition>
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="10"></ColumnDefinition>
				<ColumnDefinition Width="Auto"></ColumnDefinition>
				<ColumnDefinition Width="*"></ColumnDefinition>
				<ColumnDefinition Width="10"></ColumnDefinition>
			</Grid.ColumnDefinitions>
			<Label Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Style="{DynamicResource LabelHeader}" Content="{Binding Title, Mode=OneWay}" />
			<Label Grid.Row="1" Grid.Column="1" Style="{DynamicResource TagManagementInput}" Content="{Binding TagLabel, Mode=OneWay}" />
			<Label Grid.Row="2" Grid.Column="1" Style="{DynamicResource TagNameInput}" Content="{Binding TagNameLabel, Mode=OneWay}" />
			<Label Grid.Row="3" Grid.Column="1" Style="{DynamicResource TagManagementInput}" Content="{Binding NodeNameLabel, Mode=OneWay}" />
			<Label Grid.Row="4" Grid.Column="1" Style="{DynamicResource TagManagementInput}" Content="{Binding TaggedItemsLabel, Mode=OneWay}" />
			<Border Name="PlaceHolderBorder" Grid.Column="2" Margin="7"/>
			<ComboBox Grid.Row="1" Grid.Column="2" ItemsSource="{Binding AvailableTags}" SelectedValue="{Binding SelectedTag, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" />
			<WrapPanel Grid.Row="2" Grid.Column="2"  Width="{Binding ElementName=PlaceHolderBorder, Path=ActualWidth}">
				<TextBox Width="200" ToolTip="{Binding TagNameValidationMessage, Mode=OneWay}" Text="{Binding TagName, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" MaxLength="40" Validation.ErrorTemplate="{x:Null}" Loaded="TextBox_Loaded"/>
				<Button Command="{Binding AddCommand}" Content="{Binding AddButtonLabel}"></Button>
			</WrapPanel>
			<ComboBox Grid.Row="3" Grid.Column="2" ItemsSource="{Binding Nodes}" SelectedValue="{Binding SelectedNode, Mode=TwoWay, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{x:Null}" />
			<Border Name="PlaceHolderBorder2" Grid.Row="4" Margin="7"/>
			<ListBox Grid.Row="4" Grid.Column="2" ScrollViewer.VerticalScrollBarVisibility="Auto" Name="TaggingItems" Height="{Binding ElementName=PlaceHolderBorder2, Path=ActualHeight}" SelectionMode="Multiple" ItemsSource="{Binding ItemsToTag}" DisplayMemberPath="Name" SelectedValuePath="ID" Validation.ErrorTemplate="{x:Null}" >
				<ListBox.ItemContainerStyle>
					<Style TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemStyle}">
						<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
					</Style>
				</ListBox.ItemContainerStyle>
			</ListBox>
			<CheckBox Grid.Row="5" Grid.Column="2" Content="{Binding SelectAllLabel, Mode=OneWay}" Name="SelectAll" Click="CheckBox_Click" IsChecked="{Binding SelectAll}" />
			<StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="2" Margin="5">
				<Button Command="{Binding UpdateCommand}" Content="{Binding UpdateButtonLabel}"></Button>
				<Button Command="{Binding CloseConfirmCommand}" Content="{Binding CloseButtonLabel}"></Button>
			</StackPanel>
		</Grid>
	</ScrollViewer>
</lib:EditControl>